using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
    /// <summary>
    /// Controller class for ProdVersion
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class ProdVersionController
    {
        // Preload our schema..
        ProdVersion thisSchemaLoad = new ProdVersion();
        private string userName = string.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}

					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}

				}

				return userName;
            }

        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public ProdVersionCollection FetchAll()
        {
            ProdVersionCollection coll = new ProdVersionCollection();
            Query qry = new Query(ProdVersion.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public ProdVersionCollection FetchByID(object ProdVersionID)
        {
            ProdVersionCollection coll = new ProdVersionCollection().Where("ProdVersionID", ProdVersionID).Load();
            return coll;
        }

		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public ProdVersionCollection FetchByQuery(Query qry)
        {
            ProdVersionCollection coll = new ProdVersionCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }

        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object ProdVersionID)
        {
            return (ProdVersion.Delete(ProdVersionID) == 1);
        }

        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object ProdVersionID)
        {
            return (ProdVersion.Destroy(ProdVersionID) == 1);
        }

        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(int ProdVersionCode,string ProdVersionName,int? BrandID,int? ProductID,bool FullVideo,bool ShortVideo,string FullVideoFile,string ShortVideoFile,string PressFile,string OutDoorFile,string RadioFile,string CableFile,double PricePerSecond,int Duration,string MediaType,DateTime DateAdded,DateTime DateModified,DateTime? DateAddedTv,DateTime? DateAddedRd,DateTime? DateAddedCb,DateTime? DateAddedPr,DateTime? DateAddedOd,DateTime? DateAddedNs,DateTime? DateAddedIn,string InternetFile)
	    {
		    ProdVersion item = new ProdVersion();
		    
            item.ProdVersionCode = ProdVersionCode;
            
            item.ProdVersionName = ProdVersionName;
            
            item.BrandID = BrandID;
            
            item.ProductID = ProductID;
            
            item.FullVideo = FullVideo;
            
            item.ShortVideo = ShortVideo;
            
            item.FullVideoFile = FullVideoFile;
            
            item.ShortVideoFile = ShortVideoFile;
            
            item.PressFile = PressFile;
            
            item.OutDoorFile = OutDoorFile;
            
            item.RadioFile = RadioFile;
            
            item.CableFile = CableFile;
            
            item.PricePerSecond = PricePerSecond;
            
            item.Duration = Duration;
            
            item.MediaType = MediaType;
            
            item.DateAdded = DateAdded;
            
            item.DateModified = DateModified;
            
            item.DateAddedTv = DateAddedTv;
            
            item.DateAddedRd = DateAddedRd;
            
            item.DateAddedCb = DateAddedCb;
            
            item.DateAddedPr = DateAddedPr;
            
            item.DateAddedOd = DateAddedOd;
            
            item.DateAddedNs = DateAddedNs;
            
            item.DateAddedIn = DateAddedIn;
            
            item.InternetFile = InternetFile;
            
	    
		    item.Save(UserName);
	    }

    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int ProdVersionID,int ProdVersionCode,string ProdVersionName,int? BrandID,int? ProductID,bool FullVideo,bool ShortVideo,string FullVideoFile,string ShortVideoFile,string PressFile,string OutDoorFile,string RadioFile,string CableFile,double PricePerSecond,int Duration,string MediaType,DateTime DateAdded,DateTime DateModified,DateTime? DateAddedTv,DateTime? DateAddedRd,DateTime? DateAddedCb,DateTime? DateAddedPr,DateTime? DateAddedOd,DateTime? DateAddedNs,DateTime? DateAddedIn,string InternetFile)
	    {
		    ProdVersion item = new ProdVersion();
		    
				item.ProdVersionID = ProdVersionID;
				
				item.ProdVersionCode = ProdVersionCode;
				
				item.ProdVersionName = ProdVersionName;
				
				item.BrandID = BrandID;
				
				item.ProductID = ProductID;
				
				item.FullVideo = FullVideo;
				
				item.ShortVideo = ShortVideo;
				
				item.FullVideoFile = FullVideoFile;
				
				item.ShortVideoFile = ShortVideoFile;
				
				item.PressFile = PressFile;
				
				item.OutDoorFile = OutDoorFile;
				
				item.RadioFile = RadioFile;
				
				item.CableFile = CableFile;
				
				item.PricePerSecond = PricePerSecond;
				
				item.Duration = Duration;
				
				item.MediaType = MediaType;
				
				item.DateAdded = DateAdded;
				
				item.DateModified = DateModified;
				
				item.DateAddedTv = DateAddedTv;
				
				item.DateAddedRd = DateAddedRd;
				
				item.DateAddedCb = DateAddedCb;
				
				item.DateAddedPr = DateAddedPr;
				
				item.DateAddedOd = DateAddedOd;
				
				item.DateAddedNs = DateAddedNs;
				
				item.DateAddedIn = DateAddedIn;
				
				item.InternetFile = InternetFile;
				
		    item.MarkOld();
		    item.Save(UserName);
	    }

    }

}

